Skip to content

feat(service-knowledge): build a never-built source after boot; os knowledge rebuild and status - #37439

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-0g9cij
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-0g9cij

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #37099

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 用户看到的:知识库数据源第一次部署、或换了嵌入模型 / 索引配方之后,服务启动后会在后台自动把它建好索引,不用再等每条记录被改一遍才能搜到;管理员也可以用命令行手动重建某个源、查看每个源的索引状态和进度。
  • 为什么做:属于「知识检索平台化」专题,让知识源开箱即可检索;以前一个从没建过索引的源,搜索永远是空的。
  • 出错会怎样:建索引会把匹配到的内容发给嵌入服务商并产生费用;默认的内存存储每次重启都会整源重建、每个节点各建一次,只有配置了共享集群锁才是一个节点建;可以用插件开关关掉开机自动建,回退就是撤掉这个改动。
  • 要你做什么:无。

What changes

First build after boot (@objectstack/service-knowledge)

  • KnowledgeService.readIndexState(source) reads ADR-0161 K7's table for one source: the adapter holds nothing, a different fingerprint, a different recipe hash, no recipe hash, current, or (an adapter without indexStatus) whether listDocuments lists anything. Each reading says whether a build is due.
  • KnowledgeService.buildSourcesAtBoot() runs from the plugin's kernel:bootstrapped hook, after the embedder is provided, without holding up the boot. It walks the sources one at a time and builds each one a build is due for. A source with refresh.onRecordChange: false (an external indexer owns it) is skipped. A state it cannot read, or an adapter that cannot say, is logged at warn and left alone; the operator rebuild is the way for those.
  • One node builds. rebuildSource takes the cluster lock knowledge:build:SOURCE (ILock, 60 s lease renewed every 20 s, waitMs: 0). A node that finds the lock held records not-run and builds nothing. A node that gets the lock re-reads the state first, so a node arriving after another finished builds nothing either. If the lock service errors, no build starts and the node warns. Without a cluster service (single process) the build runs without a lock.
  • Each build logs one cost line at its start (every row the source's where matches is read, and its content fields are sent to the embedding provider, which bills for them), progress at most every 10 s, and its totals at the end (info) or why it did not finish (warn).
  • New plugin option buildAtBoot (default true). false turns the boot pass off; the operator rebuild still works.

Operator rebuild

  • Two actions on the knowledge settings namespace, beside test: rebuild ({ source }) starts a build and answers at once; index_status ({ source? }) answers each source's index reading and the last build record on this node, with its progress. Both go through the settings action door, so both need manage_platform_settings. A second rebuild of a source already building on this node is refused.
  • os knowledge rebuild SOURCE starts one and follows it to its end by polling index_status (--no-wait to return at once, --interval). It exits 1 when the build failed or did not run, or when the answer comes from a node that is not running this build.
  • os knowledge status [source] prints each source, its index state and its last build on the node that answered.

Docs: content/docs/ai/knowledge-rag.mdx gains "The first build, and rebuilding a source": the K7 table, what one build costs (a warn callout), how to turn the boot pass off, and the two commands.

Rework round (seat L1 REWORK, contract record PASS with should-fix findings)

  • S3, the admin gate is pinned. knowledge-settings-contribution.test.ts gains "the rebuild and index_status actions are administrator-only, at the HTTP door": a real LiteKernel with KnowledgeServicePlugin and SettingsServicePlugin, driven through registerSettingsRoutes and the real SettingsService.runAction. A signed-in caller without manage_platform_settings (an organization member holding setup.read / setup.write, or one with no capability) gets 403 SETTINGS_FORBIDDEN for rebuild and index_status; an unauthenticated one gets 401 UNAUTHENTICATED. No refusal names the source (id or label), and no handler method on the service (listSources, getSource, readIndexState, rebuildSource, buildRecord) is called. A control shows the same door lets an administrator through and then names the source, and the in-process runAction with an enforced member context rejects with SETTINGS_FORBIDDEN. The gate itself is unchanged; it still lives in the knowledge manifest's writePermission, and relaxing it now turns these pins red (ablation below).
  • S4, the cost callout in content/docs/ai/knowledge-rag.mdx now says the default memory adapter holds nothing after a restart, so with it every boot is a first build that re-embeds the whole source on every node; and that "only one node builds a source" holds only with a shared cluster lock driver, because the default memory cluster driver's lock is a per-process mutex. The paragraph above the callout now qualifies its "only one builds" sentence the same way and links the cluster page. The changeset says both.
  • S6, the CLI reference. content/docs/deployment/cli.mdx gains a ### Knowledge section after ### MCP, in the shape of the other command groups (overview table, one #### per command with examples, a flag table): os knowledge status and os knowledge rebuild, their exit codes, the admin-only door, and the per-node build record.
  • Nits fixed: N2 (os knowledge rebuild --no-wait now prints that it reports no outcome and points at os knowledge status; the flag help and the CLI reference say so), N3 (buildSourcesAtBoot lists the sources inside a try and resolves with a warn when it cannot; the plugin's void call carries a .catch), N5 (an adapter reporting { building: true } with no active fingerprint, a first build that never completed, now reads nothing with its own sentence instead of new-fingerprint). N1 (the optional protocol/knowledge.mdx pointer) stays an accepted deviation.
  • Carded, not fixed here: S1 (a lease that lapses mid-build only warns and the walk goes on unfenced; a build whose embed call never returns renews forever) is service-knowledge: a build that loses its lease stops at the next page, and a build has a time bound #37465. S2 (build records live in memory per node, so behind a load balancer os knowledge rebuild can exit 1 on a poll that lands elsewhere) is service-knowledge: os knowledge rebuild and status give the right answer behind a load balancer #37466. S5 (retiring the field gate's title arm) is service-knowledge: retire the field gate's title arm once a source's index is proven built under the current recipe #37467.

Why

A source that was never built had an empty index until each of its rows was written again; search found nothing and nothing said why. After an embedder or recipe change the index stayed stale the same way. ADR-0161 K7 says what starts a rebuild; nothing ran it.

Tests

  • packages/services/service-knowledge/src/__tests__/knowledge-build.test.ts (20 tests): every readIndexState reading; a fresh source is built at boot and search finds its rows; a built source is not rebuilt; two nodes sharing one lock build once (one done, one not-run, lock released); a node arriving late re-reads and builds nothing; a lock error starts nothing and warns; onRecordChange: false is skipped; a failed build is logged at warn and stays due; the rebuild and index_status actions (progress, result, an operator rebuild skipping unchanged documents, a running build refused, bad payloads refused); the plugin's kernel:bootstrapped pass and buildAtBoot: false.
  • packages/cli/src/commands/knowledge/knowledge.test.ts (7 tests): both commands against bodies written by sendOk / sendError: the route and payload, following a build to its end, exit 1 on a failed build, on a server refusal, and on an answer from a node not running this build; --no-wait.
  • Ablation: replacing lock.acquire with an always-granted handle fails the two-node and lock-unreachable tests.
  • Rework round: knowledge-settings-contribution.test.ts +10 tests (the admin-gate pins above); knowledge-build.test.ts +2 (N3: a listing that throws resolves and warns; N5: { building: true } reads nothing); knowledge.test.ts: the --no-wait case now also asserts the line naming os knowledge status (N2).
  • Rework ablations, each mutated through scripts/ablation-replace.mjs (landing proved on disk, restore proved git diff HEAD empty):
    • S3: the knowledge manifest's writePermission set to setup.write in @objectstack/service-settings, package rebuilt (the pins read its dist/): the four member cases, the admin control and the in-process case turn red (6 failed, 4 passed); restored and rebuilt, 10/10 green, and the built manifest reads writePermission: "manage_platform_settings" again.
    • N5: the new branch disabled: its test red. N3: the listing failure rethrown: its test red. N2: the log line deleted: the --no-wait test red. All three green again after restore.

Acceptance notes

Verification

  • service-knowledge: 14 test files / 436 tests pass; tsc --noEmit and check:test-typecheck pass.
  • CLI: the knowledge tests and the vitest tier partition test pass (29 tests). eslint --no-inline-config on every changed file passes.
  • CLI tsc --noEmit: not measured locally. This container has no built dist/ for the CLI's workspace dependencies (563 TS2307-family errors, none in a knowledge file); CI owns it.
  • Real kernel run: two LiteKernels sharing one MemoryLock over a 250-row source. Boot returned in 9 ms without waiting for the build. Node A: done, 250 indexed; node B: not-run ("another node holds the build"); beginBuild called once; search found row r0007; the state afterwards read current. A non-admin runAction('knowledge','rebuild') was refused ("requires the 'manage_platform_settings' capability"); an admin rebuild then showed done with 250 skipped. The log carried the cost line.
  • Derived gates: the local run's gates exit 0 except six that need a full build or full history (check:skill-examples, check:dual-build-cjs-loads, check:i18n, check:i18n-coverage, check:i18n-walk-parity, check-plugin-teardown-shape --self-test; that script's scan alone exits 0). Those six go to CI.
  • Overlap check against Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 and Retire @objectstack/knowledge-ragflow: package, settings option, docs and skill mentions #37004 (both touch knowledge-rag.mdx, Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 also packages/cli): clean at push time. The second to land merges main.
Rework round readings, head 1061045
  • service-knowledge (dependency closure rebuilt first, turbo run build --filter='@objectstack/service-knowledge^...', 18/18 tasks): pnpm test 14 files / 448 tests pass; typecheck (tsc --noEmit and check:test-typecheck, 0 files / 0 errors in the debt ledger) passes.
  • CLI: src/commands/knowledge/knowledge.test.ts 7/7 pass (unit layer). CLI tsc --noEmit not measured locally, for the reason above; CI's TypeScript Type Check owns it.
  • eslint --no-inline-config on the seven changed .ts files: exit 0.
  • Derived gates (dispatch-gates.mjs --commands, 122 commands, run on a753df9 with the changeset edit in the tree): 114 exit 0. Not measured here, left to CI: six exit 3, PREREQUISITE NOT MET, the same six the first round named (check-plugin-teardown-shape --self-test, whose positive control is pinned to a commit a shallow clone cannot reach, its scan exits 0; spec check:skill-examples, check:dual-build-cjs-loads, check:i18n, check:i18n-coverage, check:i18n-walk-parity, which read built output this container does not have); two whole-repo scans, check:query-options-erasure (its self-test passed) and check:type-check-debt, hit the 300 s per-command limit on the shared box. Re-run on 1061045: the changeset family (check-adr-0087-registration, check-changeset-no-major, check-empty-changeset, check:changeset-fixed), check:nul-bytes, check:doc-anchors, check:cli-command-ids, check:cli-examples-parity, all exit 0.
  • overlap-check before each push: clean against origin/main, feat(core): requires knowledge mounts the knowledge service and one vector store #37442, feat(spec)!: form is a metadata type of its own, and the form doors read a form over both types #37422 (shares content/docs/deployment/cli.mdx) and chore: version packages (next) #35129. Retire @objectstack/knowledge-ragflow: package, settings option, docs and skill mentions #37004 has no PR open yet.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbXkQAmjg7Hf74xDKA6

…owledge rebuild and status

After boot, KnowledgeServicePlugin reads what each object source's adapter
holds against the index fingerprint and recipe hash (ADR-0161 K7, "What
starts a rebuild") and builds, in the background and one at a time, every
source that is unbuilt, under another fingerprint or under another recipe
hash. A build runs under the cluster service's lock so one node builds a
source. The knowledge settings namespace gains the administrator's rebuild
and index_status actions; os knowledge rebuild and os knowledge status call
them. Progress and results are logged, and the docs state the cost.

Claude-Session: https://claude.ai/code/session_01JQwxbXkQAmjg7Hf74xDKA6
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/cli, @objectstack/service-knowledge, touching 67 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/cli/package.json, packages/services/service-knowledge/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/agents.mdx (via sourceIds (symbol, a top-level function))
  • content/docs/ai/knowledge-rag.mdx (via KnowledgeService (symbol, a top-level class), KnowledgeServicePlugin (symbol, a top-level class), buildAtBoot (symbol, a field of interface KnowledgeServicePluginOptions), sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading), sourceIds (symbol, a top-level function), index_status (literal, a string literal in KNOWLEDGE_INDEX_STATUS_ACTION; a string literal in KnowledgeRebuild; a string literal in KnowledgeStatus; a string literal in runKnowledgeAction), os knowledge rebuild (command, read off packages/cli/src/commands/knowledge/rebuild.ts), os knowledge status (command, read off packages/cli/src/commands/knowledge/status.ts), /api/settings/knowledge (route, a path literal in runKnowledgeAction))
  • content/docs/api/data-api.mdx (via sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading))
  • content/docs/automation/flows.mdx (via sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading))
  • content/docs/deployment/cli.mdx (via OS_CLOUD_URL (literal, a string literal in flags), OS_TOKEN (literal, a string literal in flags), index_status (literal, a string literal in KNOWLEDGE_INDEX_STATUS_ACTION; a string literal in KnowledgeRebuild; a string literal in KnowledgeStatus; a string literal in runKnowledgeAction), os knowledge rebuild (command, read off packages/cli/src/commands/knowledge/rebuild.ts), os knowledge status (command, read off packages/cli/src/commands/knowledge/status.ts), /api/settings/knowledge (route, a path literal in runKnowledgeAction))
  • content/docs/deployment/cloud-connection.mdx (via OS_CLOUD_URL (literal, a string literal in flags))
  • content/docs/deployment/environment-variables.mdx (via OS_CLOUD_URL (literal, a string literal in flags), OS_TOKEN (literal, a string literal in flags))
  • content/docs/deployment/marketplace-handbook.mdx (via OS_CLOUD_URL (literal, a string literal in flags))
  • content/docs/deployment/publish-and-preview.mdx (via OS_CLOUD_URL (literal, a string literal in flags))
  • content/docs/kernel/cluster.mdx (via startedAt (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeBuildView))
  • content/docs/kernel/runtime-services/push-service.mdx (via OS_CLOUD_URL (literal, a string literal in flags))
  • content/docs/kernel/runtime-services/sharing-service.mdx (via sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading))
  • content/docs/permissions/sharing-rules.mdx (via /:object/:id/shares (route, bridged from symbol sourceId — its route source's handler names it))
  • content/docs/protocol/knowledge.mdx (via KnowledgeService (symbol, a top-level class), KnowledgeServicePlugin (symbol, a top-level class), reindexSource (symbol, a method of class KnowledgeService), sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading), sourceIds (symbol, a top-level function), getSource (literal, a string literal in KnowledgeBuildActionsService), listSources (literal, a string literal in KnowledgeBuildActionsService))

⛔ 4 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via sourceIds (symbol, a top-level function))
  • content/docs/releases/v18/18-0.mdx (via sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading))
  • content/docs/releases/v18/18-4.mdx (via sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading))
  • content/docs/releases/v18/18-6.mdx (via sourceId (symbol, a field of interface KnowledgeBuildRecord; a field of interface KnowledgeIndexReading), /:object/:id/shares (route, bridged from symbol sourceId — its route source's handler names it))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/cli/package.json, packages/services/service-knowledge/src/index.ts) — pages documenting those are invisible to this run
  • 22 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 43 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a46efa8c625f2b43d4aa1aa1044eb702667ba07d → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 67bf557f73711286ffb93c60c7019518887a5433 — the merge of head 1061045e49d4f7c5ed116c87cfe010d232f78614 into base a46efa8c625f2b43d4aa1aa1044eb702667ba07d, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 67bf557f73711286ffb93c60c7019518887a5433 && git checkout 67bf557f73711286ffb93c60c7019518887a5433
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a46efa8c625f2b43d4aa1aa1044eb702667ba07d 1061045e49d4f7c5ed116c87cfe010d232f78614 && git checkout -B drift-repro a46efa8c625f2b43d4aa1aa1044eb702667ba07d && git merge --no-ff 1061045e49d4f7c5ed116c87cfe010d232f78614

node scripts/docs-audit/affected-docs.mjs --json a46efa8c625f2b43d4aa1aa1044eb702667ba07d

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs a46efa8c625f2b43d4aa1aa1044eb702667ba07d → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 3681410 · 2026-11-26T06:22Z

The seat runs the at-tier contract review of this head through an isolated sub-agent; L1 is the seat's own.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 368141040945d223d96ef1094b612afec96f43b5
Local-runs: none
Security-touching: yes

PR #37439 for card #37099 (epic #37000). Face: declaration (Clause-②: yes, new public CLI surface). Read: the card body and all 11 comments (takeover 7184309245 included), epic comment 7183567323, the PR body, the net diff (14 files, +1770/−5), the head's check-runs, and source on main and on the head. Nothing was built, run or re-run.

Check-runs on the head: every run concluded success or skipped; none failed, and no name appears twice with differing conclusions. Check Changeset, Lint · repo & tooling gates, PR-body guards, Governed Surface Queue Guard, TypeScript Type Check, Test Core (10/10 shards) and Build Docs are all success. The CLI tsc the dev could not measure locally is covered by TypeScript Type Check and Type Check · workspace.

① Derived judgments

Card acceptance

  • Fresh deployment, one source, existing rows, searchable after boot: met. buildSourcesAtBoot runs from kernel:bootstrapped after provideEmbedder; test "a fresh deployment with one source and existing rows".
  • Two nodes, one build: met with a shared lock. rebuildSource takes knowledge:build:SOURCE with waitMs: 0; a boot build re-reads the state once it holds the lock. See S1 and S4 for the edges.
  • A built source is not rebuilt at boot: met (current and listed-documents are not due).
  • The operator entry rebuilds and reports: met on one node; see S2 for several nodes.
  • Item 4, the cost in the docs: met (the warn callout in content/docs/ai/knowledge-rag.mdx); see S4 for one missing case.
  • Container run: the PR body reports a two-kernel run; CI is green.

The build lock's lease against long builds (previous seat's point 1)

  • A healthy long build keeps its lease: 60 s, renewed every 20 s, each renewal armed after the last settles. LockHandle.renew is required by the contract (packages/spec/src/contracts/cluster-service.ts:141), and both in-repo drivers (memory, Redis) implement it. This is the same pattern service-job uses (cron-job-adapter.ts, job scheduler: the cluster lock a scheduled fire holds is never renewed, so on several nodes a run that outlasts the 60 s lease overlaps a second node's fire of the same job #31843).
  • A crashed builder cannot leave the lock stuck: it stops renewing, and the key frees itself within 60 s. Its in-memory running record dies with the process.
  • S1 (should-fix) — A lease can still lapse mid-build (the lock store unreachable for over 40 s, or a renewal that hangs), and the walk then continues unfenced: it only warns, never checks isHeld() between pages, and does not pass the fencing token down. A second node's boot pass can then build the same source. The result is double embedding spend, not a corrupt index (same document ids and hashes; generation stores take their own builder lock in beginBuild). The opposite edge also exists: a build whose embed call never returns renews forever, and nothing but a restart cancels it, while the same node refuses a second rebuild. Stopping the walk at the next page once the lease is lost, and a bound on a build, can be a follow-up row.

Admin-only rebuild and status on every door (previous seat's point 2)

  • REST: POST /api/settings/knowledge/rebuild and /index_status are the only network door. SettingsService.runAction calls assertPermitted(manifest, 'write', ctx) before the handler lookup (settings-service.ts:3949), the route context is enforced, and the knowledge manifest sets both readPermission and writePermission to manage_platform_settings (knowledge.manifest.ts:47-48). An anonymous or non-admin caller gets 403 before either handler runs, so status leaks no source name.
  • MCP: no door. The only non-test caller of SettingsService.runAction in the tree is settings-routes.ts:472; the MCP bridge's runAction is the object-action seam and does not reach settings actions.
  • CLI: os knowledge rebuild and status call that REST route with a bearer token; they add no door.
  • Actions: neither is registered as an object action (engine.registerAction), so the /actions routes do not serve them.
  • In process: rebuildSource and readIndexState are on KnowledgeService, not on IKnowledgeService; an in-process caller is trusted, as it already is for reindexSource.
  • No door is unguarded.
  • S3 (should-fix) — No test in this PR pins the gate. knowledge-build.test.ts calls the handlers directly, so the whole authorization of an action that spends money rests on a manifest value in another package. One pin (an enforced context without manage_platform_settings is refused for both actions through runAction) would catch a later relaxation of that manifest's writePermission.

Per-node build records against the card (previous seat's point 3)

  • S2 (should-fix) — Card item 3 asks that progress and the last result be "readable by the operator entry". The record is in memory on the node that ran the build and is gone on restart. Behind a load balancer os knowledge status reaches the building node only by chance, and os knowledge rebuild exits 1 as soon as a poll lands on another node, although the build continues and may succeed; a script reads that as a failure. The PR declares this, the server log carries the result on every node's own log, and the index state is read from the store and is the same everywhere, so it does not block. A follow-up row should either share the record or let the CLI fall back to the index state (due turning current).

The field gate's title arm (previous seat's point 4)

  • Agreed: it is its own row. Retiring a security gate needs per-source proof at search time that the index was built under the current recipe, and this PR only makes the rebuild happen. The gate stays, so nothing is weakened here.
  • S5 (should-fix) — No card number carries it. The dev report names "the epic seat" as carrier, and that seat has since signed off (takeover 7184309245). File the row and name its number in the PR body before merge.

Docs

  • N1 (nit) — The pointer in content/docs/protocol/knowledge.mdx (previous seat's point 5, in the takeover's file surface as "if added") is optional. That page stays accurate: lines 575-577 say nothing runs a reindex on a schedule, which is still true. A one-line pointer to the new section would help.
  • S4 (should-fix) — The cost callout misses one case. The default adapter is memory, which holds nothing after a restart, so every boot is a first build and sends the whole source to the embedding provider again; it is also per process, so each node builds its own. The same paragraph says "with several server nodes, only one builds a source", which holds only with a shared cluster driver: the memory lock is a per-process mutex (cluster-service.ts:149). One or two sentences fix both.
  • S6 (should-fix) — os knowledge rebuild and os knowledge status are not in content/docs/deployment/cli.mdx, the CLI reference that lists the other commands (for example os mcp connect, line 3838). The PR body declares the omission. It can ride the next push.

Boot-time build

  • It does not block boot: the hook calls void this.service.buildSourcesAtBoot() and returns.
  • It runs on every node; the lock and the re-read leave one builder (with a shared driver, see S4).
  • No knowledge service mounted means no pass; buildAtBoot: false turns the pass off and keeps the operator rebuild. There is no enabled setting on the namespace to respect.
  • An unconfigured embedder reads as unreadable or fails the build with a warning; nothing is claimed built.
  • A source with refresh.onRecordChange: false, a file or http source, and an adapter that cannot say are all left alone.
  • N3 (nit) — buildSourcesAtBoot documents "never rejects", but listSources() sits outside its try, and the call site has no .catch. A .catch on the void call closes it.
  • N5 (nit) — A first build that crashed part-way (building: true, no fingerprint) reads as new-fingerprint ("built under another fingerprint"). It is still due, so only the sentence is wrong.

Settings contribution

  • contributeKnowledgeSettings gains an optional third argument and registers the two actions only when the service is passed. The manifest, the test action, the embedder section and the Setup entry are unchanged, and a composition with no settings service still gets nothing. The new actions have no action_button, so the Setup page does not change; the PR says so.

CLI

  • N2 (nit) — os knowledge rebuild --no-wait exits 0 after "started" even when the build then ends not-run (another node holds the lock). The help text could say that --no-wait does not report the outcome.

② Semver level

  • patch on @objectstack/service-knowledge and @objectstack/cli is the right level. Metadata-protocol: none is correct: nothing a metadata author writes changes (buildAtBoot is a plugin option, packages/spec is untouched, IKnowledgeService is unchanged). AGENTS.md: none takes patch, and a non-protocol widening ships patch.
  • Clause-②: yes is correct: new CLI commands, new exports, a new plugin option, two new settings actions. Per scripts/pm/clause2-line.mjs, yes and yes (widening) read the same; the arm is optional and nothing is owed.
  • Both lines are in the PR body and in the changeset body. Nothing is removed or renamed, so no BREAKING banner, migration or ADR-0087 disposition is owed. Check Changeset is success.
  • One thing for a reader of the changelog: the boot pass is on by default, so an upgraded deployment with a never-built source sends that source to its embedding provider at the next boot. The card asks for exactly this, and the changeset's "What it costs" bullet says it.

③ Boundary flags

No must-fix. S1 to S6 are should-fix: S4, S5 and S6 are small enough to ride the next push; S1, S2 and S3 can be follow-up rows if the seat prefers.

Implemented-by: claude/project-thread-0g9cij
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 368141040945d223d96ef1094b612afec96f43b5
REWORK — L1, seat repo:objectstack#5: contract record 7184443506 reads PASS with six should-fix findings. Three are fixed in this PR (a security pin and two docs gaps). Three close as cards named in the PR body, following the maintainer's rule that non-blocking issues become follow-up cards.

  1. Shape: open draft against main, 14 files (+1770/−5), Fixes #37099, Clause-②: yes (bare yes reads as widening), Metadata-protocol: none, patch. The PR was taken over by ai-37000 (7184309245). l1-face is CLEAN: 41 success, 15 expected skip, 0 failed.
  2. Premise: no door is unguarded. REST is the only network door, SettingsService.runAction checks manage_platform_settings before the handler lookup, and a non-admin gets 403 with no source name. The boot build does not block boot, and buildAtBoot: false turns it off. A crashed builder's lock frees itself within 60 s. There is no SQL push-down finding.
  3. Owed in this PR:
    • S3. Pin the admin gate. A non-admin rebuild and index_status through the real runAction path answer 403 and name no source. Today authorization rests on knowledge.manifest.ts:47-48 in another package, with no test here.
    • S4. In the docs cost callout, add two facts. The default memory adapter is empty after every restart, so every boot re-embeds the whole source on each node. "Only one node builds" holds only with a shared cluster lock driver; the memory lock is per process.
    • S6. Add os knowledge rebuild and status to content/docs/deployment/cli.mdx.
      Cards, under service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099 or 专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000, named in the PR body:
    • S1. A lease that lapses mid-build only warns, and the walk goes on unfenced, so two nodes can build the same source (double embedding spend). A build whose embed call never returns renews forever.
    • S2. Build records live in memory per node. Behind a load balancer, os knowledge rebuild exits 1 when a poll lands on another node.
    • S5. The field gate's title arm gets its own row. Its named carrier has signed off.
      The same reviewer reads the delta.
  4. Accepted deviations: N1 (the optional knowledge.mdx pointer; that page is still accurate). Nits for the same push if cheap: N2 (--no-wait exits 0 on a later not-run), N3 (void buildSourcesAtBoot() has no .catch, and listSources() sits outside the try), N5 (a part-built first build reads as new-fingerprint).
  5. Out of scope and where it went: lease fencing goes to the S1 card, shared build records to the S2 card, and the title arm to the S5 card.
  6. Landing terms: ungoverned, default tier, Security-touching: yes. A same-head PASS with S3, S4 and S6 closed and S1, S2 and S5 carded, plus an ACCEPT, are owed. The area lands it. Coordinate the landing order with o5-A's Retire @objectstack/knowledge-ragflow: package, settings option, docs and skill mentions #37004 and ai-37000's feat(core): requires knowledge mounts the knowledge service and one vector store #37442, which share content/docs/ai/knowledge-rag.mdx.

…s; docs and CLI follow-ups

- The rebuild and index_status settings actions are refused 403
  SETTINGS_FORBIDDEN to a caller without manage_platform_settings, through
  the real settings action door, naming no source and reaching no handler.
- The cost callout says the default memory adapter is empty after every
  restart (each boot re-embeds the whole source on each node), and that
  one builder per source needs a shared cluster lock driver.
- os knowledge rebuild --no-wait says it reports no outcome.
- buildSourcesAtBoot lists the sources inside its try, and its background
  call carries a catch.
- A first build that opened a generation and never completed reads as
  nothing built, not as another fingerprint.

Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ
Co-authored-by: Claude <noreply@anthropic.com>
…ry is answered 401

Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ
Co-authored-by: Claude <noreply@anthropic.com>
…adapter rebuilds at every boot; --no-wait reports no outcome

Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 1061045 · 2026-11-26T07:25Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 1061045e49d4f7c5ed116c87cfe010d232f78614
Local-runs: none
Security-touching: yes

Delta review of PR #37439 for card #37099 (epic #37000), on top of the record for head 368141040945d223d96ef1094b612afec96f43b5. Face: declaration (Clause-②: yes). Read: git diff 368141040945d223d96ef1094b612afec96f43b5..1061045e49d4f7c5ed116c87cfe010d232f78614 (4 commits, 10 files, +229/−11, no rebase, no main merge), the PR body at this head, os-dev report 7185409049, cards #37465, #37466 and #37467, and the head's check-runs. Nothing was built, run or re-run.

Check-runs on the head: 42 success, 17 skipped, 0 failed, and one not yet concluded. Check Changeset appears twice: the run started 06:57:57Z concluded success; a newer run started 07:25:24Z (after the PR body was rewritten) was still in_progress on three reads. The newer run governs, so that gate has no verdict at the time of this record. The changeset file and both declaration lines are unchanged in kind since the run that passed, so no red is expected, but the seat confirms the newer run's conclusion before landing. PR-body guards also appears twice; both runs are success.

① Derived judgments

Findings of the previous record

  • S1: carried — card service-knowledge: a build that loses its lease stops at the next page, and a build has a time bound #37465 (open). Its acceptance covers both edges: the walk checks the lease before each page and stops with a recorded result, and a build has a bound. The PR body names it. The behaviour on this head is unchanged and is stated in the docs warning that a renewal failure is logged.
  • S2: carried — card service-knowledge: os knowledge rebuild and status give the right answer behind a load balancer #37466 (open). Its acceptance offers the two fixes the record named (a shared record, or the CLI falling back to the index state) and asks for a test on a poll that lands on another node. The PR body names it, and the new CLI reference states the limit.
  • S3: closed. knowledge-settings-contribution.test.ts boots a real LiteKernel with KnowledgeServicePlugin and SettingsServicePlugin and drives registerSettingsRoutes and the real SettingsService.runAction. A member holding setup.read and setup.write, and a signed-in caller with no capability, get 403 SETTINGS_FORBIDDEN on rebuild and on index_status; an anonymous caller gets 401 UNAUTHENTICATED. Each case asserts the refusal carries neither the source id nor its label, and that none of the five service methods the handlers use was called. The admin control proves the same door then names the source, so "names no source" is not vacuous. The in-process case asserts runAction rejects an enforced member with required: 'manage_platform_settings'. The reported ablation (the manifest's writePermission set to setup.write: 6 red) is the right one. The gate itself is unchanged.
  • S4: closed. The callout in content/docs/ai/knowledge-rag.mdx now says the default memory adapter is empty after a restart, so every boot re-embeds the whole source on every node, and that one builder needs a shared cluster lock driver. The paragraph above it is qualified the same way (OS_CLUSTER_DRIVER=redis, which the tree reads, with a link to content/docs/kernel/cluster.mdx, which exists). The changeset says both.
  • S5: closed. Card service-knowledge: retire the field gate's title arm once a source's index is proven built under the current recipe #37467 (open) carries the title arm, with a no-weakening acceptance and a reverse pin. The PR body names it.
  • S6: closed. content/docs/deployment/cli.mdx gains a ### Knowledge section after ### MCP: both commands, examples, exit codes, the admin-only door, the per-node record, the cost, and a flag table. It matches the code on this head (defaults, env names, exit behaviour).
  • N1: accepted as a deviation. The pointer was optional, and content/docs/protocol/knowledge.mdx is still accurate.
  • N2: closed. --no-wait now logs that the outcome is not reported and points at os knowledge status; the flag help, the docblock, the changeset and the CLI reference agree. The test asserts the line.
  • N3: closed. buildSourcesAtBoot lists the sources inside a try and resolves with a warning; the plugin's void call carries a .catch that warns. The test drives a throwing listSources.
  • N5: closed. An adapter answering building: true with no fingerprint now reads nothing, due, with its own sentence; the state's docblock says so. The test asserts state, due and held.

New in the delta

  • No new finding. The N5 branch only changes which due state is named: every status it catches was already due, so no source that was left alone is now built and none that was built is now skipped.
  • The other code changes are a log line, a .catch and a try; none touches the lock, the gate or the walk.

content/docs/frontend/cli.mdx

  • Acceptable, and not a gap. That page documents @object-ui/cli, a separate objectui binary for ObjectUI applications; it lists no os command. os knowledge belongs in content/docs/deployment/cli.mdx, where it now is. The PR body's note that the page is "not updated" can simply say it is another product's page.

② Semver level

  • Unchanged and still right: patch on @objectstack/service-knowledge and @objectstack/cli, Clause-②: yes, Metadata-protocol: none, in the PR body and in the changeset body. The delta adds no export, option, action or flag; it adds one log line, a changed sentence for one reading, and prose.
  • The changeset edit (three sentences for S4 and N2) is to an unreleased note, so it corrects nothing published.
  • Check Changeset: see the check-run note above; the newer run's conclusion is still owed.

③ Boundary flags

No must-fix and no open should-fix on this head. S1 and S2 are carried by open cards. One landing condition: the newer Check Changeset run concludes success.

Implemented-by: claude/project-thread-0g9cij
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 1061045e49d4f7c5ed116c87cfe010d232f78614
ACCEPT — L1, seat repo:objectstack#5

  1. Shape: open draft against main, Fixes #37099, Clause-②: yes, Metadata-protocol: none. Not governed, 1993 lines ≤ 3000. The rework is 4 commits on 368141040, with no rebase and no main merge.
  2. Rework closed (delta contract record 7185497292, same head):
    • S3: closed. A real LiteKernel test covers rebuild and index_status: a member and a caller without the capability get 403, anonymous gets 401. No refusal names the source. An admin control and the in-process runAction case are included, and the ablation fails 6 cases.
    • S4: closed. The cost callout covers memory-adapter re-embedding on every boot and node, plus the shared cluster lock driver.
    • S6: closed. The Knowledge section in content/docs/deployment/cli.mdx matches the code.
    • N2, N3 and N5: closed, each with a test.
  3. Gates: check-runs at 1061045e: 43 success, 17 expected skip, 0 failed, 0 pending. The newer Check Changeset run, started after the body patch, has concluded.
  4. Accepted deviations:
    • N1: the optional pointer is not added; content/docs/protocol/knowledge.mdx is still accurate.
    • content/docs/frontend/cli.mdx lists no os command because it documents the separate objectui binary, so it is not a gap.
  5. Out of scope and where it went: S1 goes to service-knowledge: a build that loses its lease stops at the next page, and a build has a time bound #37465, S2 to service-knowledge: os knowledge rebuild and status give the right answer behind a load balancer #37466 and S5 to service-knowledge: retire the field gate's title arm once a source's index is proven built under the current recipe #37467. All three are open sub-issues of 专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000 and named in the PR body.
  6. Landing terms: ungoverned, default tier, no open must-fix or should-fix. The area marks it ready and lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6Cb4BAjgQ43tqy1DvVJ

Landing · 2026-11-26T07:30Z · zone ai-37000

Probe Reading
Head 1061045e49d4f7c5ed116c87cfe010d232f78614 = ACCEPT 7185511593 head (delta contract record 7185497292 PASS)
Checks on head skipped=17 success=43, 0 failure
Governed check-governed-merges.mjs --pr 37439: NOT governed, 1993 lines ≤ 3000

State change: ready for review + auto-merge (merge queue). #37099 closes on merge; close-out follows. knowledge-rag.mdx siblings (#37442, #37004) merge main after this lands.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 26, 2026 07:30
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

service-knowledge: a source that was never built gets built, and an operator can start a rebuild

3 participants